home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / gotoxy.c < prev    next >
C/C++ Source or Header  |  1988-12-15  |  1KB  |  78 lines

  1. /* gotoxy.c -- 9/5/88, d.c.oshel
  2.  
  3.    These are the functions that directly affect the machine cursor,
  4.    and CIAO's soft cursor screen write location.
  5.    */
  6.  
  7.  
  8. #include "vidinit.h"
  9.  
  10.  
  11. void setmchnloc( void )  /* the ROM-BIOS gotoxy function */
  12. {
  13.     static union REGS xy;
  14.  
  15.     xy.h.ah = 2;
  16.     xy.h.bh = 0;
  17.     xy.h.dh = row;
  18.     xy.h.dl = col;
  19.     int86( 0x10, &xy, &xy );
  20. }
  21.  
  22.  
  23. void setcursize( int r1, int r2 )
  24. {
  25.     union REGS rx;
  26.  
  27.     rx.h.ah = 1;
  28.     rx.h.ch = r1;
  29.     rx.h.cl = r2;
  30.     int86( 0x10, &rx, &rx );
  31. }
  32.  
  33.  
  34. /* RELATIVE TO TOPLEFT CORNER (0,0) OF CURRENT WINDOW! */
  35. void gotoxy( int x, int y ) 
  36. {
  37.     if (!Initialized) vid_init(0);
  38.  
  39.     y %= 1 + bm - tm;  /* mod number of lines in window */
  40.     x %= 1 + rm - lm;  /* mod number of columns in line */
  41.  
  42.     row = tm + y;      /* translate window-relative to fullscreen-absolute */
  43.     col = lm + x;
  44.  
  45.     if (synchronized)  /* update machine cursor? */
  46.         setmchnloc();
  47. }
  48.  
  49.  
  50. void clrscrn( void )
  51. {
  52.     if (!Initialized) vid_init(0);
  53.  
  54.     lm = tm = row = col = 0;
  55.     rm = 79;
  56.     bm = 24;
  57.     gotoxy(0,0);
  58.     MSJ_SetFldAttr( SPC, row, col, vid_attr, 2000, &video );
  59. }
  60.  
  61.  
  62. void clreol( void )
  63. {
  64.     if (!Initialized) vid_init(0);
  65.  
  66.     MSJ_SetFldAttr( SPC, row, col, vid_attr, rm-col+1, &video );
  67. }
  68.  
  69.  
  70. void clreos( void )
  71. {
  72.     if (!Initialized) vid_init(0);
  73.  
  74.     clreol();
  75.     MSJ_ClrRegion( row+1, lm, bm, rm, vid_attr );
  76. }
  77.  
  78.